package com.vf.admin.miaodong.controller;

import com.vf.admin.common.BaseController;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.AppUserLoginRecord;
import com.vf.admin.miaodong.service.AfterUserLoginRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 用户登录日志记录
 */
@Controller
@RequestMapping("/after/userlogin")
public class AfterUserLoginRecordController extends BaseController{
    @Autowired
    AfterUserLoginRecordService appUserLoginRecordService;

    /**
     * 用户登录日志列表
     * @param splitPageBean
     * @param startDate  开始时间
     * @param endDate   结束时间
     * @param nick   用户昵称
     * @param phone  用户手机号
     * @return
     */
    @RequestMapping("/list")
    public String list(SplitPageBean splitPageBean,String startDate,String endDate,String nick,String phone, String deviceModel, String packageName){
        try{
            Map<String,Object> map = new HashMap<>();
            map.put("startDate",startDate);
            map.put("endDate",endDate);
            map.put("nick",nick);
            map.put("phone",phone);
            map.put("deviceModel",deviceModel);
            map.put("packageName",packageName);
            List<AppUserLoginRecord> list = appUserLoginRecordService.list(map,splitPageBean);

            request.setAttribute("list",list);
            request.setAttribute("splitPage",splitPageBean);
            request.setAttribute("startDate",startDate);
            request.setAttribute("endDate",endDate);
            request.setAttribute("nick",nick);
            request.setAttribute("phone",phone);
            request.setAttribute("deviceModel",deviceModel);
            request.setAttribute("packageName",packageName);
            return this.sucess("/web/after/userlogin/list");
        }catch (Exception e){
            return this.error("系统繁忙");
        }
    }

}
